package com.mywork.mvpkodeinxml.model.response

import androidx.room.Entity
import androidx.room.PrimaryKey
import org.simpleframework.xml.Attribute
import org.simpleframework.xml.Element
import org.simpleframework.xml.ElementList
import org.simpleframework.xml.Root

@Root(name = "xml", strict = false)
class UserListEntity : BaseEntity() {

    @get:Element(name = "items")
    @set:Element(name = "items")
    var items: UserItems = UserItems()

    @Root(name = "items", strict = false)
    class UserItems(
        @get:Attribute(name = "pageindex", required = false)
        @set:Attribute(name = "pageindex", required = false)
        var pageindex: String = "",

        @get:Attribute(name = "pagesize", required = false)
        @set:Attribute(name = "pagesize", required = false)
        var pagesize: String = "",

        @get:Attribute(name = "pagecount", required = false)
        @set:Attribute(name = "pagecount", required = false)
        var pagecount: String = "",

        @get:Attribute(name = "recordcount", required = false)
        @set:Attribute(name = "recordcount", required = false)
        var recordcount: String = "",

        @get:ElementList(required = false, inline = true, entry = "item")
        @set:ElementList(required = false, inline = true, entry = "item")
        var UserList: List<UserItem> = arrayListOf()
    ) {
        @Entity(tableName = "Users")
        @Root(name = "items", strict = false)
        class UserItem(
            @get:Attribute(name = "SM_CODE", required = false)
            @set:Attribute(name = "SM_CODE", required = false)
            var SM_CODE: String = "",

            @get:Attribute(name = "SM_TITLE", required = false)
            @set:Attribute(name = "SM_TITLE", required = false)
            var SM_TITLE: String = "",

            @get:Attribute(name = "SD_NAME", required = false)
            @set:Attribute(name = "SD_NAME", required = false)
            var SD_NAME: String = "",

            @get:Attribute(name = "SU_ID", required = false)
            @set:Attribute(name = "SU_ID", required = false)
            var SU_ID: String = "",

            @get:Attribute(name = "SU_CODE", required = false)
            @set:Attribute(name = "SU_CODE", required = false)
            var SU_CODE: String = "",

            @get:Attribute(name = "SU_NAME", required = false)
            @set:Attribute(name = "SU_NAME", required = false)
            var SU_NAME: String = "",

            @PrimaryKey
            @get:Attribute(name = "IDX", required = false)
            @set:Attribute(name = "IDX", required = false)
            var IDX: String = ""
        ){
            override fun toString(): String {
                return "UserItem(SM_CODE='$SM_CODE', SM_TITLE='$SM_TITLE', SD_NAME='$SD_NAME', SU_ID='$SU_ID', SU_CODE='$SU_CODE', SU_NAME='$SU_NAME', IDX='$IDX')"
            }
        }
    }


}
